package com.tangly.codeing.utils;

import java.io.Serializable;

/**
 * common return
 *
 * @author tangbing
 * @date 2019/4/28
 */
public class ReturnT<T> implements Serializable {
    public static final long serialVersionUID = 42L;

    public static final int SUCCESS_CODE = 200;
    public static final int FAIL_CODE = 500;
    public static final int FAIL_TOKEN_CODE = 401;
    public static final ReturnT<String> SUCCESS = new ReturnT<>("");
    public static final ReturnT<String> FAIL = new ReturnT<>(FAIL_CODE, "操作失败");
    /**
     * token过期时间五分钟 5 * 60 * 1000
     */
    public static final long TOKEN_INDATE = 60L* 1000L* 60L * 24L *7L;

    private int code;
    private String msg = "";
    private T data;

    public ReturnT(int code, String msg) {
        this.code = code;
        this.msg = msg;
        this.data = (T) "";
    }

    public ReturnT(T data) {
        this.code = SUCCESS_CODE;
        this.data = data;
        this.msg = "操作成功";
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

}
